﻿<Sample:InstallerControl x:Class="OMS.Water.Sample.Views.PrepareInstallView"
                         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                         xmlns:Sample="clr-namespace:OMS.Water.Sample"
                         xmlns:Converter="clr-namespace:OMS.Water.Sample.Converter"
                         xmlns:localizer="clr-namespace:Systecs.Framework.WPF.Resources;assembly=Systecs.Framework.WPF"
                         mc:Ignorable="d"
                         d:DesignHeight="520"
                         d:DesignWidth="800">

	<Sample:InstallerControl.Resources>

		<ResourceDictionary>

			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="..\Resources\ButtonGreen.xaml" />
			</ResourceDictionary.MergedDictionaries>

			<Converter:PackageStateToImageConverter x:Key="PackageStateToImageConverter" />

		</ResourceDictionary>


	</Sample:InstallerControl.Resources>

	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>

		<Grid Grid.Row="0"
		      Margin="30,30,30,0">
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto" />
				<RowDefinition />
			</Grid.RowDefinitions>

			<TextBlock Grid.Row="0"
			           Text="{localizer:Resx Key=PrepareInstallView.Header, FallbackValue=Packages:}"
			           Margin="0,0,0,10" />

			<Border Grid.Row="1"
			        BorderThickness="1"
			        BorderBrush="DarkGray"
			        CornerRadius="5">
				<ListBox ItemsSource="{Binding Bootstrapper.Packages}"
				         BorderThickness="0"
				         Margin="10">
					<ListBox.Resources>
						<Style TargetType="ListBoxItem">
							<Setter Property="Template">
								<Setter.Value>
									<ControlTemplate TargetType="{x:Type ListBoxItem}">
										<Border Margin="6,6,6,6"
										        BorderThickness="0,0,0,1"
										        BorderBrush="DarkGray">
											<Border.Resources>
												<Style TargetType="TextBlock">
													<Setter Property="TextBlock.FontSize"
													        Value="14" />
												</Style>
											</Border.Resources>
											<Grid>
												<Grid.ColumnDefinitions>
													<ColumnDefinition Width="*" />
													<ColumnDefinition Width="200" />
												</Grid.ColumnDefinitions>
												<TextBlock Grid.Column="0"
												           Text="{Binding PackageName}"
												           Margin="5,0,0,0" />
												<StackPanel Grid.Column="1"
												            Orientation="Horizontal">
													<Image Source="{Binding Path=State, Converter={StaticResource PackageStateToImageConverter}}"
													       Width="24"
													       Height="24"
													       Margin="0,1,5,1" />
													<TextBlock Text="{Binding Path=State}"
													           VerticalAlignment="Center" />
												</StackPanel>
											</Grid>
										</Border>
									</ControlTemplate>
								</Setter.Value>
							</Setter>
						</Style>
					</ListBox.Resources>
				</ListBox>

			</Border>

		</Grid>

		<Button Grid.Row="1"
		        Content="{localizer:Resx Key=Button.Install, FallbackValue=Install}"
		        Command="{Binding InstallCommand}"
		        HorizontalAlignment="Center"
		        VerticalAlignment="Center" />
	</Grid>
</Sample:InstallerControl>